package com.common.www.repository.programme;

import org.springframework.boot.base.jpa.repository.support.ExtendedRepository;
import com.common.www.bean.entity.programme.TabulationExtracting;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface TabulationExtractingRepository extends ExtendedRepository<TabulationExtracting, Long> {

    /**
     * 按“公司、项目”查询
     * @param flag
     * @param projectId
     * @param supplyCompanyId
     * @return
     */
    List<TabulationExtracting> findByFlagAndProjectIdAndSupplyCompanyIdAndInnerOuterType(Integer flag, Long projectId, Long supplyCompanyId,Integer innerOuterType);

    /**
     * 按条件查询
     * @param flag
     * @param projectId
     * @param jieDuan
     * @return
     */
    List<TabulationExtracting> findByFlagAndProjectIdAndJieDuan(Integer flag, Long projectId, Integer jieDuan);


    /**
     * 按条件查询
     * @param flag
     * @param projectId
     * @param jieDuan
     * @param innerOuterType
     * @return
     */
    List<TabulationExtracting> findByFlagAndProjectIdAndJieDuanAndInnerOuterType(Integer flag, Long projectId, Integer jieDuan,Integer innerOuterType);

    /**
     * 按条件查询供应商清单
     * @param flag
     * @param projectId
     * @param jieDuan 2,3,4,5,6,8
     * @return
     */
    TabulationExtracting findByFlagAndProjectIdAndJieDuanAndInnerOuterTypeAndSupplyCompanyId(Integer flag, Long projectId, Integer jieDuan,Integer innerOuterType,Long supplyCompanyId);

    /**
     * 按阶段、内外线、项目删除
     * @param projectId
     * @param type
     * @return
     */
    @Modifying
    @Transactional
    int deleteByProjectIdAndInnerOuterTypeAndJieDuan(Long projectId,Integer type,Integer jieDuan);


    /**
     * 按阶段、内外线、项目、供应商删除
     * @param projectId
     * @param type
     * @param jieDuan
     * @param supplyCompanyId
     * @return
     */
    @Modifying
    @Transactional
    int deleteByProjectIdAndInnerOuterTypeAndJieDuanAndSupplyCompanyId(Long projectId,Integer type,Integer jieDuan,Long supplyCompanyId);

}
